#include "DoubleList.h"


DoubleList::DoubleList(void)
{
	pHead=NULL;
}


DoubleList::~DoubleList(void)
{

	if(pHead!=NULL){
		Node* pTemp;
		Node* pCur=pHead;
		while(pCur->get_right()!=NULL){
			pTemp=pCur;
			pCur=pCur->get_right();
			delete pTemp;
		}
	}
}

void DoubleList::insert(int key){
	Node* pNew=new Node;

	if(pHead==NULL){
		pHead=pNew;
		pHead->set_data(key);
	}
	else{
		Node* pCur=pHead;
		pNew->set_data(key);

		while(pCur->get_right()!=NULL){
			pCur=pCur->get_right();
		}

		pCur->set_right(pNew);
		pNew->set_left(pCur);
	}
}
void DoubleList::print(){
	Node* pCur=pHead;
	cout<<"--------------------------------------"<<endl;
	while(pCur->get_right()!=NULL){
		cout<<pCur->get_data()<<" ";
		pCur=pCur->get_right();
	}
	cout<<endl;
}